<html>

<head>
    <title>zPromise源码</title>
    <meta name="keywords" content="shopInfo.shopName?if_exists" />
    <meta name="description" content="shopInfo.shopName?if_exists" />
    <meta http-equiv="X-UA-Compatible" content="IE=8">
    </meta>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0">
</head>

<body>

    <div id="app" class="body" style="text-align: center;">
		<div style="color:red;">点击屏幕可执行等待promise</div>
    </div>

    <script src="zPromise.js"></script>
    <script>
        window.onload = function () {

            var b = function (message) {
                return new MyPromise(function (resolve, reject) {
                    document.body.onclick = function () {
                        resolve('我点击了屏幕' )
                    }
                })
            }
            

            var a = new MyPromise(function (resolve, reject) {
                let node = document.createElement("div");
                node.setAttribute('style', 'text-align: center;margin-top: 20px;');
                node.appendChild( document.createTextNode("步骤1成功") ) 
                document.body.append( node );
                setTimeout(function(){
                    resolve("哈哈")
                }, 500)
            }).then(function (message) {
                let node = document.createElement("div");
                node.setAttribute('style', 'text-align: center;margin-top: 20px;');
                node.appendChild( document.createTextNode('步骤2（步骤1返回：' + message + ')') );
                document.body.append( node );
                return b(message)
            }).then().then(function (message) {
                let node = document.createElement("div");
                node.setAttribute('style', 'text-align: center;margin-top: 20px;');
                node.appendChild( document.createTextNode('步骤2（步骤1返回：' + message + ')') );
                document.body.append( node );
            },function (err) {
                document.body.append('final:' + err)
            })
			
        }
    </script>

	<div style="position: fixed;bottom: 0;text-align: center;width: 100%;padding: 15px 0;background-color: #bfd6e8;color: white;font-size:14px;">
		<div style="font-size:15px;">欢迎访问主页</div>
		<div>个人主页：
			<a style="color:white;" target="_blank" href="http://www.zhuangweizhan.cn">www.zhuangweizhan.cn</a>
		</div>
		<div>个人github：
			<a style="color:white;" target="_blank" href="https://github.com/zhuangweizhan">https://github.com/zhuangweizhan</a>
		</div>
		<div>个人博客：
			<a style="color:white;" target="_blank" href="https://juejin.im/user/4195392104696519">https://juejin.im/user/4195392104696519</a>
		</div>
	</div>
	
</body>

</html>